using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Windows.Forms;

namespace ApplicationProject
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void Form2_Load(object sender, EventArgs e)
        {
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                DirectoryInfo dir = new 
                    DirectoryInfo(@"C:\WINDOWS\");
                int i = 1;
                int max = dir.GetFiles("*.*").Length;
                progressBar1.Maximum = max;
                foreach (FileInfo d in dir.GetFiles("*.*"))
                {
                    label1.Text = d.Name;
                    progressBar1.Value = i;
                    int j=Convert.ToInt32(
                    Math.Floor(Convert.ToDouble(i*100 / max)));
                    label2.Text = Convert.ToString(j) + "%";
                    i++;
                    Application.DoEvents();
                    
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void progressBar1_Click(object sender, EventArgs e)
        {

        }
    }
}